 
#ifndef __MUD_MUDCORE_MUDCORE__HEADER_FILE__
#define __MUD_MUDCORE_MUDCORE__HEADER_FILE__

#include "coid/svc/coidsvc.h"

#include "coid/comm/dynarray.h"
#include "coid/comm/keywordt.h"

#include "coid/svc/coidsvc.h"
#include "../mudport/client/mudport_client.h"


#include "jonsky.h"

////////////////////////////////////////////////////////////////////////////////
struct MudCore : public StenchMud
{

public:

    net_fnc_s
    opcd accept_startup_params( cmd_interface& cmd )
    {
        _cmdin = &cmd;
        return 0;
    }
    
    net_fnc_s
    opcd accept_connect_auto()    // initialize
    {
        return StenchMud::init();
    }

    net_fnc_s
    opcd accept_spawn()  //main thread (heartbeat)
    {
        _cmdin->set_option( cmd_interface::OPTION_ALLOW_SHARED_ACCESS, 1 );
        return StenchMud::run();
    }

    net_fnc_d
    opcd register_client( net_in uint obj )
    {
        *_clients_new.add(1) = obj;
        return 0;
    }

    net_fnc_d
    opcd unregister_client( net_in uint obj )
    {
        if( _clients_connected.erase(obj) )
            return 0;
        _clients_new.del_key(obj);
        return 0;
    }
    //net_fnc opcd send( net_in const charstr& str );
	net_fnc_d
	opcd get_creature(net_in const charstr &str, net_out net_ptr void **cr) 
	{ 
		/*Creature *crtmp;
		World* world = World::create(); 
		world->getByString(crtmp, String(str)); 
		*cr = (void*)crtmp;*/
		return 0;
	}

	net_fnc_d
	opcd send_intro_screen(net_inout dynarray<charstr> *arr)
	{
		charstr str;

		str << COL_BACK_BLACK;
		str << "Welcome to  "<< COL_YELLOW <<"S t e n c h  O f  D e a d.\r\n" << COL_ORIGINAL;
		arr->push(str);
		str.reset();
		str << "(c)1990-2003 " << COL_GREEN << "PrickEar Brothers" << COL_ORIGINAL<< ".\r\n";
		arr->push(str);
		arr->push("\r\n");
		str.reset();
		str << "powered by <" << COL_RED << "COID" << COL_ORIGINAL <<">\r\n";
		arr->push(str);
		arr->push("\r\n");
		arr->push("\r\n");
		return 0;
	}
};

#endif //__MUD_MUDCORE_MUDCORE__HEADER_FILE__
